import { service as request, postForm } from '@/utils/request'


/**
 * 根据条件查询机房
 * @param {*} data 
 * @returns 
 */

export function queryComputerRoom (data) {

  var params = data.query
  return request({
    // params: data.query,
    url: `/hawk/computer-room/search/${data.page.current}/${data.page.size}`,
    method: 'post',
    data: data.query
  })
}



// 返回当前用户部门下没有视图的机房 根据id查询机房
export function getNoCiRoom () {
  return request({
    url: `/hawk/computer-room/get/view`,
    method: 'get',
  })
}



// 根据 ID 查机房
export function getOneById (id) {

  return request({
    url: `/hawk/computer-room/get/${id}`,
    method: 'get',
  })
}




/**
 * 判断机房编号是否存在
 * @param {*} data 
 * @returns 
 */
export function isRoomNumExists (query) {

  return request({
    url: `/hawk/computer-room/exists/${query.companyId}/${query.areaId}`,
    method: 'get',
    params: {number:query.number}
  })
}



export function getAll () {
  return request({
    // params: data.query,
    url: `/hawk/computer-room/search/1/10000`,
    method: 'post',
    data: {
      areaId: "",
      companyId: "",
      computeRoomName: "",
      deptId: "",
      principalName: ""
    }
  })
}

/**
 * 添加机房
 * @param {*} data 
 * @returns 
 */
export function doAdd (data) {
  console.log("添加机房");
  return request({
    url: '/hawk/computer-room/save',
    method: 'post',
    data
  })
}
export function doEdit (data) {
  return request({
    url: '/hawk/computer-room/update',
    method: 'put',
    data
  })
}
/**
 * 删除主机 
 * @param {*} data 主机id 数组
 * @returns 
 */
export function doDelete (data) {
  return request({
    url: `/hawk/computer-room/del`,
    method: 'delete',
    data
  })
}
export function getOne (id) {
  return request({
    url: `/assets/list/room/${id}`,
    method: 'get'
  })
}

export function getDepartmentList () {
  return request({
    url: 'company/department',
    method: 'get'
  })
}
export function getPrincipalList () {
  return request({
    url: 'assets/principal',
    method: 'get'
  })
}
export function getAreaList () {
  return request({
    url: 'assets/area',
    method: 'get'
  })
}
